package com.szx.usercenter.util;

/**
 * @author songzx
 * @create 2024-06-07 13:39
 */
public class FileTypeUtil {
    /**
     * 是否是图片类型的文件
     */
    public static boolean isImage(String fileName) {
        String[] imageSuffix = {"jpg", "jpeg", "png", "gif", "bmp", "webp"};
        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
        for (String s : imageSuffix) {
            if (s.equals(suffix)) {
                return true;
            }
        }
        return false;
    }

    /**
     * 是否是视频文件
     */
    public static boolean isVideo(String fileName) {
        String[] videoSuffix = {"mp4", "avi", "rmvb", "mkv", "flv", "wmv"};
        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1);
        for (String s : videoSuffix) {
            if (s.equals(suffix)) {
                return true;
            }
        }
        return false;
    }
}
